package com.tenement.service.impl;

import com.github.pagehelper.PageHelper;
import com.tenement.dao.TenementLogMapper;
import com.tenement.domain.TenementLog;
import com.tenement.service.LogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @ClassName : LogServiceImpl  //类名
 * @Description : 日志服务接口实现类  //描述
 * @Author : 易嵘  //作者
 * @Date: 2020-06-27 09:27  //时间
 */
@Service
public class LogServiceImpl implements LogService {

    @Resource
    TenementLogMapper logMapper;

    @Override
    public int add(TenementLog log) {
        return logMapper.insertSelective(log);
    }

    @Override
    public int delete(String id) {
        return logMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<TenementLog> findAll(TenementLog log, String startDate, String endDate, Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        return logMapper.findAll(log,startDate,endDate);
    }

    @Override
    public Long overCount(TenementLog log, String startDate, String endDate) {
        return logMapper.overCount(log,startDate,endDate);
    }

    @Override
    public int deleteAll(String[] ids) {
        List<String> list=new ArrayList<>(Arrays.asList(ids));
        return logMapper.deleteAll(list);
    }

    @Override
    public TenementLog findById(String logId) {
        return logMapper.selectByPrimaryKey(logId);
    }
}